package com.linkage.util.password;

/**
 * <p>Title: password</p>
 * <p>Description: Process all password</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: linkage</p>
 * @author lijq
 * @version 1.0
 */
import com.linkage.util.password.des3.*;


public class PwdDES3 implements PwdAPI{
  //private Des3 d3 = null;
  public PwdDES3() {
    //d3 = new Des3();
  }
  public String encryptPassword(String plaintext) throws Exception {
    Des3 d3 = new Des3();
    return d3.Encrypt(plaintext).trim();
  }
  public String decryptPassword(String cryptograph) throws Exception {
    Des3 d3 = new Des3();
    return d3.Decrypt(cryptograph).trim();
  }
  public boolean checkPassword(String plaintext, String cryptograph) throws Exception {
  	if (plaintext == null || cryptograph == null) return false;
    Des3 d3 = new Des3();
  	String decrypt = d3.Decrypt(cryptograph);
    return plaintext.trim().equals(decrypt.trim());
  }
}